const dailyDao = require('./dao/dailyDao');

async function testDailyDao() {
  try {
    console.log('🧪 测试 dailyDao.getTodaySentence 方法...');

    // 测试获取今日一句
    const sentence = await dailyDao.getTodaySentence();
    console.log('✅ dailyDao.getTodaySentence 方法调用成功');
    console.log('📊 结果:', sentence ? {
      id: sentence.id,
      chinese: sentence.chinese,
      pinyin: sentence.pinyin,
      date: sentence.date
    } : '无今日句子');

    // 测试获取每日一句列表
    console.log('\n🧪 测试 dailyDao.getDailySentences 方法...');
    const options = {
      page: 1,
      limit: 5
    };

    const result = await dailyDao.getDailySentences(options);
    console.log('✅ dailyDao.getDailySentences 方法调用成功');
    console.log('📊 结果:', {
      total: result.total,
      page: result.page,
      limit: result.limit,
      sentencesCount: result.sentences.length
    });

    // 测试根据日期获取每日一句
    console.log('\n🧪 测试 dailyDao.getDailySentenceByDate 方法...');
    const today = new Date().toISOString().split('T')[0];
    const todaySentence = await dailyDao.getDailySentenceByDate(today);
    console.log('✅ dailyDao.getDailySentenceByDate 方法调用成功');
    console.log('📊 今日句子:', todaySentence ? {
      id: todaySentence.id,
      chinese: todaySentence.chinese,
      date: todaySentence.date
    } : '无今日句子');

    console.log('\n🎉 所有测试通过！');

  } catch (error) {
    console.error('❌ 测试失败:', error.message);
    console.error('📋 错误详情:', error.stack);
  }
}

testDailyDao();
